package praktikumid.w07.p2;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * 
 * @author Gert Kanter
 *
 */

class MyButtonActionListener implements ActionListener {
	public void actionPerformed(ActionEvent e) {    
	    System.out.println("click" + e.getModifiers());
	}
}

public class FrameExample extends JFrame {

	/**
	 * @param args
	 */
	
	public static void main(String[] args) {

		FrameExample frame = new FrameExample();
		frame.setTitle("Example title");
		frame.setVisible(true);
		frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
		frame.setLocation(300, 300);
		frame.setSize(400, 400);
		
		JPanel leftPanel = new JPanel();
		leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));
		leftPanel.setBackground(new Color(100, 100, 100));
		leftPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
		//frame.getContentPane().setLayout(new BorderLayout());
		frame.getContentPane().add(leftPanel, BorderLayout.WEST);
		JButton jbtn = new JButton("Button name");
		jbtn.setFont(new Font("Arial", Font.BOLD, 18));
		leftPanel.add(jbtn);
		
		MyButtonActionListener myListener = new MyButtonActionListener();
		jbtn.addActionListener(myListener);
		
		leftPanel.add(Box.createRigidArea(new Dimension(0, 5)));
		leftPanel.add(new JButton("Another button"));
		
		JPanel rightPanel = new JPanel();
		rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));
		rightPanel.setBackground(new Color(255, 255, 255));
		rightPanel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
		
		JLabel label1 = new JLabel("some text");
		label1.setFont(new Font("Arial", Font.BOLD, 26));
		rightPanel.add(label1);
		
		frame.getContentPane().add(rightPanel, BorderLayout.CENTER);
		
		frame.pack();
		
		frame.repaint();
		
		leftPanel.setBackground(Color.GREEN);
	}

}
